var ifdetail;
function Chide(){
	var idarr = ['party_detail_C1','party_detail_C2','party_detail_C3','party_detail_C4'];
	for(var i=0;i<idarr.length;i++){o(idarr[i]).hide();}
}	
function PTuA(uid){
	zeai.openurl(MHOST+'/u.php?uid='+uid);
}
function party_detail1btnFn(){
	tabmenu_onclk({obj:party_detail_nav,li:this});
	Chide();party_detail_C1.show();
}
function party_detail2btnFn(){
	tabmenu_onclk({obj:party_detail_nav,li:this});
	Chide();party_detail_C2.show();
}
function party_detail3btnFn(){
	tabmenu_onclk({obj:party_detail_nav,li:this});
	Chide();party_detail_C3.show();
}
function party_detail4btnFn(){
	tabmenu_onclk({obj:party_detail_nav,li:this});
	Chide();party_detail_C4.show();
}
function party_detail_bm_btnFn(){
	var mobV = o('mob').value,verifyV=o('verify').value;
	if(!zeai.ifmob(mobV)){zeai.msg('请输入正确【手机号码】',o('mob'));return false;}
	if(!zeai.ifint(verifyV) || zeai.str_len(verifyV)!=4 ){zeai.msg('请输入【手机验证码】',o('verify'));return false;}
	var truenameV=o('truename').value;
	if(zeai.str_len(truenameV) < 2 || zeai.str_len(truenameV)>12){zeai.msg('请输入【真实姓名】',{time:3,focus:o('truename')});return false;}
	if(!zeai.form.ifradio('sex')){zeai.msg('请选择您的【性别】');return false;}
	if(zeai.str_len(o('birthday').value) !=4 ){zeai.msg('请输入【出生年份，如：1995】',{time:3,focus:o('birthday')});return false;}
	ZeaiM.confirmUp({title:'确定信息无误提交报名么？',cancel:'取消',ok:'确定',okfn:function(){
	zeai.ajax({url:MHOST+'/party_detail'+zeai.extname,form:Www_Zeai_cn_PartyBm},function(e){var rs=zeai.jsoneval(e);
		zeai.msg(rs.msg);
		if(rs.flag==1)zeai.openurl(MHOST+'/party_detail'+zeai.ajxext+'submitok=ajax_bm_add_update_pay&fid='+rs.fid);
	});}});	
}
function htmlspecialchars_decode(str){
  str = str.replace(/&amp;/g, '&'); 
  str = str.replace(/&lt;/g, '<');
  str = str.replace(/&gt;/g, '>');
  str = str.replace(/&quot;/g, "'");  
  str = str.replace(/&#039;/g, "'");  
  return str;  
}
function party_bbs_btnFn(){
	ZeaiM.confirmUp({title:'确定要发表么？',cancel:'取消',ok:'确定',okfn:function(){
	zeai.ajax({url:MHOST+'/party_detail'+zeai.extname,form:Www_Z_e_a_i_C_n_Party},function(e){var rs=zeai.jsoneval(e);
		zeai.msg(rs.msg);
		if(rs.flag==1){
			party_bbsbox.insertAdjacentHTML('afterbegin',htmlspecialchars_decode(rs.list));
			bbsnum.html(parseInt(bbsnum.innerHTML)+1);
			content.value='';
			bbsnum.removeClass('nodata');
		}else if(rs.flag=='nologin'){
			setTimeout(function(){zeai.openurl(MHOST+'/login'+zeai.ajxext+'jumpurl='+encodeURIComponent(rs.jumpurl))},2000)
		}
	});}});	
}
function party_bmbtnFn(fid){
	zeai.ajax({url:MHOST+'/party_detail'+zeai.ajxext+'submitok=ajax_bm_ifpay&fid='+fid},function(e){var rs=zeai.jsoneval(e);
		if(rs.ifpay==1){
			//已报名未缴费
			zeai.openurl(MHOST+'/party_detail'+zeai.ajxext+'submitok=ajax_bm_add_update_pay&fid='+fid);
		}else{
			//报名页面
			zeai.ajax({url:MHOST+'/party_detail'+zeai.ajxext+'submitok=ajax_bm_add&fid='+fid,js:1},function(e2){var rs2=zeai.jsoneval(e2);
				if(rs2.flag==1){
					zeai.openurl(MHOST+'/party_detail'+zeai.ajxext+'submitok=ajax_bm_add&fid='+fid);
				}else{
					if(rs2.flag==0){
						zeai.msg(rs2.msg);
					}else{
						ZeaiM.sorry(rs2);
					}
				}
			});
		}
	});
}
function partyshareFn(){ZeaiM.div_up({fobj:ZEAI_MAIN,obj:partysharebox,h:15});}
function setArticle_C(obj) {
	if (obj) {
		var iframeWin = obj.contentWindow || obj.contentDocument.parentWindow;
		if (iframeWin.document.body){obj.height = iframeWin.document.documentElement.scrollHeight || iframeWin.document.body.scrollHeight;}
	}
}
window.onload=function(){
	if(ifdetail){
		document.body.onscroll = function(){backtopFn();}
		wxshare.onclick = function(){div_up_close.click();zeai.showSwitch('share_mask,share_box');}
		share_mask.onclick = function(){zeai.showSwitch('share_mask,share_box');}
		share_box.onclick = function(){zeai.showSwitch('share_mask,share_box');}
		cardcontent.addEventListener('touchmove',function(e) {e.preventDefault();});
		zeai_haibaobtn.onclick=Zeai_makecardFn;
		tabmenu({obj:party_detail_nav});
		setTimeout(function(){party_detail1btn.click();},200);
		party_detail1btn.onclick=party_detail1btnFn;
		//party_detail2btn.onclick=party_detail2btnFn;
		party_detail3btn.onclick=party_detail3btnFn;
		party_detail4btn.onclick=party_detail4btnFn;
		party_bmbtn.onclick=function(){party_bmbtnFn(fid)};
		party_bbsbtn.onclick=function(){party_detail4btn.click();content.focus();}
		party_bbs_btn.onclick=party_bbs_btnFn;
		partyshare.onclick = partyshareFn;
		party_kefubtn.onclick=party_kefubtnFn;
		setArticle_C(o('article_C'));
		//
		if(flag==1){
			var B = o('djsbox').getElementsByTagName('font');
			var Did = B[0],Hid = B[1],Mid=B[2],Sid=B[3];
			var diftime = o('djsbox').getAttribute("diftime");
			bm_djs(Did,Hid,Mid,Sid,diftime);
		}
	}
}
function party_kefubtnFn(){
	console.log(party_detail1btn);
	party_detail1btn.click();
	setTimeout(function(){zeai.setScrollTop(99999);},100);
}
function copy(str) {
	zeai.copy(str,function(){
		zeai.msg('复制成功');div_up_close.click();	
	})
}
function Zeai_makecardFn() {
	card_detail.show();
	zeai.msg('<img src="'+HOST+'/res/loadingData.gif" class="middle">正在生成',{time:10})
	html2canvas(cardcontent).then(function(canvas) {
		var cW=canvas.width,cH=canvas.height;
		var img = Canvas2Image.convertToImage(canvas,cW, cH);
		if(is_h5app()){
			zeai.msg(0);
			app_save_share({durl:HOST,data:img.src,uid:0});					
		}else{
			cardbox_view.html('');
			img.style.width='80%';
			img.id='fximgs';
			cardbox_view.append(img);
			img.onload=function(){
				zeai.msg(0);
				setTimeout(function(){
					div_up_close.click();
					var ww=cardbox_view.offsetWidth/10;
					var hh=cardbox_view.offsetHeight/10;
					ZeaiM.div_pic({fobj:o(card_detail),obj:cardbox_view,title:'',w:ww,h:hh,fn:function(){
						card_detail.hide();
						o('cardbox_view').html('');
					}});
					zeai.msg('长按图片保存，发送给朋友',{time:3});							
				},200);
			}
		}
	});
}

function tabmenu(json){
		function init(json){
			var showbox=json.showbox;
			var elem=zeai.tag(json.obj,'li');
			var ZminiEtabAmenuI_cn=zeai.tag(json.obj,'i')[0];
			zeai.listEach(elem,function(li){
				if (li.hasClass('ed')){
					var span = li.getElementsByTagName("span")[0];
					var iW = span.offsetWidth;
					var iL = span.offsetLeft;
					iL=iL+iW/2-4;
					ZminiEtabAmenuI_cn.css('width:8px;transform:translate('+iL+'px)');
				}
				var url=li.getAttribute("data");
				if (!zeai.empty(url)){
					li.onclick = function(){
						tabmenu_onclk({obj:json.obj,li:li,kind:json.kind});
						if (!zeai.empty(showbox)){
							var url=this.getAttribute("data");
							zeai.ajax({'url':url},function(e){
								ZeaiM.dojsFunc(e,function(e){o(showbox).html(e);ZeaiM.eval(e);});
								if (!zeai.empty(p) && p>1)p=1;
							});
						}
						if(!zeai.empty(json.click))json.click(li);
					}
				}
			});
		}
}
function tabmenu_onclk(json){
	var ZminiEtabAmenuI_cn=zeai.tag(json.obj,'i')[0];
	zeai.listEach(zeai.tag(json.obj,'li'),function(li){li.removeClass('ed');});
	json.li.addClass('ed');
	var span = json.li.getElementsByTagName("span")[0],iL,iW;
	if(json.kind=='block'){
		iL = json.li.offsetLeft;
		iW = json.li.offsetWidth;
	}else{
		iL = span.offsetLeft;
		iW = span.offsetWidth;
	}
	iL=iL+iW/2-4;
	ZminiEtabAmenuI_cn.css('width:8px;transform:translate('+iL+'px)');
}
function yzmtimeFn(countdown) { 
	if (countdown == 0) {
		yzmbtn.removeClass('disabled');
		yzmbtn.html('<font>重新获取</font>'); 
		return false;
	} else { 
		if (!zeai.empty(o('yzmbtn'))){
			yzmbtn.addClass('disabled');
			yzmbtn.html('<b>'+countdown + "S</b>后重新发送"); 
			countdown--; 
		}
	} 
	cleandsj=setTimeout(function(){yzmtimeFn(countdown)},1000);
}
function bm_djs(Did,Hid,Mid,Sid,intDiff) {
	var tmpid = window.setInterval(function () {
		var day=0,hour = 0,minute = 0,second = 0;
		if (intDiff > 0){
			day = Math.floor(intDiff/(60*60*24)),
			hour = Math.floor(intDiff/(60*60)%24),
			minute = Math.floor(intDiff/60%60),
			second = Math.floor(intDiff%60);
			if (hour <= 9) hour = '0' + hour;
			if (minute <= 9) minute = '0' + minute;
			if (second <= 9) second = '0' + second;
			Did.html(day);
			Hid.html(hour);
			Mid.html(minute);
			Sid.html(second);
			intDiff--;
		}else{
			window.location.reload();
		}
	}, 1000);
}